#ifndef STREAMRECORDERWITHFAILOVER_H
#define STREAMRECORDERWITHFAILOVER_H

#include "streamrecorderconfig.h"
#include <QObject>

class StreamRecorderController;

class StreamRecorderWithFailover : public QObject
{
    Q_OBJECT
public:
    StreamRecorderWithFailover(const StreamRecorderConfig& config, const QStringList& urls,
                               QObject* parent = nullptr);
    ~StreamRecorderWithFailover();

    bool isRunning() const;
    void start();
    void stop();
    void terminate();

Q_SIGNALS:
    void positionChanged(qint64 pos);
    void qosMetrics(double fps, double bitrate);
    void finished(const QString& filename, qint64 duration);
    void errorOccurred(int error, const QString& message);

private:
    void onError(int error, const QString& message);

    StreamRecorderConfig config_;
    QStringList urls_;
    int index_ = 0;
    StreamRecorderController* stream_recorder_ = nullptr;
};

#endif // STREAMRECORDERWITHFAILOVER_H
